package hmis.pos.Controller;


import hmis.pos.Entity.RoomMessage;
import hmis.pos.Service.RoomMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("roomMessage")
@CrossOrigin(origins={"http://localhost:3000"})
public class RoomMessageController {

    @Autowired
    private RoomMessageService roomMessageService;

    @RequestMapping("save")
    @ResponseBody
    public RoomMessage save(@RequestBody RoomMessage roomMessage){
        return roomMessageService.save(roomMessage);
    }

    @RequestMapping("delete")
    @ResponseBody
    public boolean delete(@RequestBody RoomMessage roomMessage){
        return roomMessageService.delete(roomMessage);
    }

    @RequestMapping("update")
    @ResponseBody
    public RoomMessage update(@RequestBody RoomMessage roomMessage){
        return roomMessageService.update(roomMessage);
    }

    @RequestMapping("findById")
    @ResponseBody
    public RoomMessage findById(@RequestParam String id){
        return roomMessageService.findById(id);
    }

    @RequestMapping("findAll")
    @ResponseBody
    public List<RoomMessage> findAll(){
        return roomMessageService.findAll();
    }

    @RequestMapping("findByType")
    @ResponseBody
    public List<RoomMessage> findByType(@RequestParam String type){
        return roomMessageService.findByType(type);
    }
}
